<!DOCTYPE html>
<html lang="en" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/custom.form.css">
</head>
<body>
<div class="panel panel-default operation_house" hidden>
    <div class="panel-heading title"></div>
    <div class="layui-card-body">
        <form class="layui-form layui-form-pane" action="" lay-filter="houseInfo" style="width: 700px;margin-top: 10px">
            <input name="homeid" hidden/>
            <input name="funid" hidden>
            <input name="houserid" hidden>
            <div class="layui-form-item">
                <div class="layui-form-label ">房屋号</div>
                <div class="layui-input-block">
                    <input type="housename" name="housename" placeholder="请输入房屋号" autocomplete="off"
                           class="layui-input" style="background:#eeeeee!important">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">房屋面积</div>
                <div class="layui-input-block">
                    <input type="floorspace" name="floorspace" placeholder="请输入房屋面积" autocomplete="off"
                           class="layui-input" style="background:#eeeeee!important">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">位置</div>
                <div class="layui-input-block">
                    <input type="area" name="area" placeholder="请输入位置" autocomplete="off"
                           class="layui-input" style="background:#eeeeee!important">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">楼层</div>
                <div class="layui-input-block">
                    <input type="level" name="level" placeholder="请输入楼层" autocomplete="off"
                           class="layui-input" style="background:#eeeeee!important">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">房屋名称</div>
                <div class="layui-input-block">
                    <input type="housename" name="homename" placeholder="请输入房屋名称" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">门牌号</label>
                <div class="layui-input-block">
                    <input type="homenum" name="homenum" placeholder="请输入门牌号" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">区域面积</label>
                <div class="layui-input-block">
                    <input type="regionspace" name="regionspace" placeholder="请输入区域面积" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ">功能划分</label>
                <div class="layui-input-inline">
                    <input type="text" name="fun" id="fun" class="layui-input"
                           style="position:absolute;z-index:2;width:90%;" lay-verify="required" value=""
                           onkeyup="searchfun()" autocomplete="off">
                    <select name="Handoverfun" id="Handoverfun" lay-filter="Handoverfun" lay-search="" lay-verify="required">
                        <option value="">请选择功能类型</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">使用类型</div>
                <div class="layui-input-inline">
                    <input type="text" name="funuse" id="funuse" class="layui-input"
                           style="position:absolute;z-index:2;width:90%;" lay-verify="required" value=""
                           onkeyup="searchuse()" autocomplete="off">
                    <select name="Handoverfunuse" id="Handoverfunuse" lay-filter="Handoverfunuse" lay-search="" lay-verify="required">
                        <option value="" >请选择使用类型</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">管理部门</label>
                <div class="layui-input-inline">
                    <input type="text" name="depart" id="depart" class="layui-input" style="position:absolute;z-index:2;width:90%;" lay-verify="required" value="" onkeyup="search()" autocomplete="off">
                    <select name="Handoverdepart" id="Handoverdepart" lay-filter="Handoverdepart">
                        <option value="" >请选择管理部门</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">调配使用部门</label>
                <div class="layui-input-inline">
                    <input type="text" name="deploy" id="deploy" class="layui-input"
                           style="position:absolute;z-index:2;width:90%;" lay-verify="required" value=""
                           onkeyup="searcher()" autocomplete="off">
                    <select name="Handoverdeploy" id="Handoverdeploy" lay-filter="Handoverdeploy">
                        <option value="" >请选择调配使用部门</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">入驻企业</div>
                <div class="layui-input-block">
                    <input type="enterprise" name="enterprise" placeholder="请输入入驻企业" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">实训项目</div>
                <div class="layui-input-block">
                    <input type="forclass" name="forclass" placeholder="请输入实训项目" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">备注</div>
                <div class="layui-input-block">
                    <input type="remark" name="remark" placeholder="请输入备注" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">其他一</div>
                <div class="layui-input-block">
                    <input type="detailone" name="detailone" placeholder="请输入备注" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">其他二</div>
                <div class="layui-input-block">
                    <input type="detailtwo" name="detailtwo" placeholder="请输入备注" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label">其他三</div>
                <div class="layui-input-block">
                    <input type="detailthree" name="detailthree" placeholder="请输入备注" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="status" lay-skin="switch" lay-filter="switch" lay-text="启用|禁用" checked>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
                    <button class="layui-btn layui-btn-primary" id="btn_cancel">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>
<div class="panel panel-default operation_houser" hidden>
    <div class="panel-heading title"></div>
    <div class="layui-card-body">
        <form class="layui-form layui-form-pane" action="" lay-filter="houseInfo" style="width: 700px;margin-top: 10px">
            <div class="layui-form-item">
                <div class="layui-form-label ">房屋号</div>
                <div class="layui-input-block">
                    <input type="housename" name="housename" placeholder="请输入房屋号" autocomplete="off"
                           class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">房屋面积</div>
                <div class="layui-input-block">
                    <input type="floorspace" name="floorspace" placeholder="请输入房屋面积" autocomplete="off"
                           class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">位置</div>
                <div class="layui-input-block">
                    <input type="area" name="area" placeholder="请输入位置" autocomplete="off"
                           class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-form-label ">楼层</div>
                <div class="layui-input-block">
                    <input type="level" name="level" placeholder="请输入楼层" autocomplete="off"
                           class="layui-input" >
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="submiter">保存</button>
                    <button class="layui-btn layui-btn-primary" id="btn_canceler">返回</button>
                </div>
            </div>
        </form>
    </div>
</div>


<div class="house_table_div">
        <div id="searchParam" shiro:hasPermission="sys:indoor:list">
            <div class="layui-form-item">

                <span style="font-weight: bolder">功能类型:</span>
                <div class="layui-input-block" id="searchForm"></div>
                <span style="font-weight: bolder">管理部门:</span>
                <div style="margin-left: 12px" class="layui-input-block" id="searchForm1" ></div>

                <div class="layui-input-inline">
                    <input type="text" id="searContent" name="searContent" class="layui-input" autocomplete="off" placeholder="查询">
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn" id="search">查询</button>
                </div>
            </div>
        </div>

    <div>
        <button type="button" class="layui-btn"  id="upLoad">
            <i class="layui-icon">&#xe67c;</i>上传数据
        </button>
        <button type="button" class="layui-btn" id="start">开始上传</button>
    </div>


        <table class="layui-hide" id="house_table" lay-filter="house_table"></table>
        <div id="laypage" class="layui-laypage-btn">
        </div>
    </div>

<div id="source" style="width: 600px;height:400px;"></div>
<div id="roles" class="demo-transfer" style="display: none"></div>
</body>

<script type="text/html" id="toolbar">
    <div class="layui-btn-group">
        <button type="button" class="layui-btn" lay-event="addHouse" >
            <i class="layui-icon">&#xe608;</i> 新增房屋
        </button>
        <button  type="button" class="layui-btn" lay-event="getCheckData">
            <i class="layui-icon">&#xe608;</i> 批量删除
        </button>

    </div>
</script>
<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit" shiro:hasPermission="sys:indoor:update">编辑</a>
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="addIndoor" shiro:hasPermission="sys:indoor:add">添加</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" shiro:hasPermission="sys:indoor:deleted">删除</a>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script src="/js/excel/echarts.min.js"></script>
<script>
    var table = layui.table;
    var laypage = layui.laypage
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var tree = layui.tree;
    var transfer = layui.transfer;
    var upload = layui.upload;
    //上传文件
    layui.use(['table', 'laypage', 'layer', 'laydate', 'tree', 'transfer','upload', 'element'], function () {
        upload.render({
            elem: '#upLoad'
            ,url: '/sys/upload'
            ,auto: false
            ,field:'file'
            ,accept: 'file'
            ,async:true
            ,multiple: true
            ,bindAction: '#start'
            ,done: function(res){
                layer.msg('上传成功');
                console.log(res)
            }
        });
        var searchParam = {
            funs:null,
            searContent:null,
            pageNum: 1,
            pageSize: 10
        };

        CoreUtil.sendAjax("/sys/indoors", JSON.stringify(searchParam), function (res) {
            laypageTable(res.data.totalRows, searchParam.pageNum);
            if (res.data.list != null) {
                loadTable(res.data.list);
            }
        }, "POST", false, function (res) {
            layer.msg("抱歉！您暂无获取用户列表的权限");
            var noAuthorityData = [];
            loadTable(noAuthorityData);
        });
        //查询分页
        var laypageTable = function (count, currentPage) {
            laypage.render({
                elem: 'laypage'
                , count: count
                , limit: searchParam.pageSize
                , layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
                , curr: location.hash.replace('#!currentPage=', '') //获取起始页
                , hash: 'currentPage' //自定义hash值
                , jump: function (obj, first) {
                    if (!first) {
                        searchParam.pageNum = obj.curr;
                        searchParam.pageSize = obj.limit;
                        CoreUtil.sendAjax("/sys/indoors", JSON.stringify(searchParam), function (res) {
                            if (res.data.list != null) {
                                loadTable(res.data.list);
                                laypageTable(res.data.totalRows, searchParam.pageNum);
                            }

                        }, "POST", false, function (res) {
                            layer.msg("抱歉！您暂无获取用户列表的权限");
                            var noAuthorityData = [];
                            loadTable(noAuthorityData);
                        });
                    }
                }
            });
        };
        //渲染table
        var loadTable = function (data) {
            table.render({
                elem: '#house_table'
                , cols: [
                    [
                        {type: 'checkbox', fixed: 'left'},
                        {field: 'homeid', title: 'ID', width: 80},
                        {field: 'floorspace', title: '面积', width: 150, sort: true},
                        {field: 'area', title: '区域', width: 100},
                        {field: 'housename', title: '房屋名称', width: 100},
                        {field: 'level', title: '楼层', width: 120},
                        {field: 'homename', title: '房屋名称', width: 150},
                        {field: 'homenum', title: '门牌号', width: 100},
                        {field: 'regionspace', title: '面积', width: 40},
                        {field: 'fun', title: '功能划分', width: 100},
                        {field: 'funuse', title: '使用类型', width: 100},
                        {field: 'depart', title: '管理部门', width: 100},
                        {field: 'deploy', title: '调配使用部门', width: 100},
                        {field: 'enterprise', title: '入驻企业', width: 100},
                        {field: 'forclass', title: '实训项目', width: 100},
                        {field: 'createTime', title: '创建时间', width: 100},
                        {field: 'updateTime', title: '更新时间', width: 100},
                        {field: 'remark', title: '备注', width: 120},
                        {field: 'detailone', title: '其他一', width: 80},
                        {field: 'detailtwo', title: '其他二', width: 80},
                        {field: 'detailthree', title: '其他三', width: 80},
                        {
                            field: 'status',width:100, title: '状态', templet: function (item) {
                                if (item.status === 0) {
                                    return '  <input type="checkbox" lay-skin="switch" lay-text="启用|禁用" checked disabled>';
                                }
                                if (item.status === 1) {
                                    return '  <input type="checkbox" lay-skin="switch" lay-text="启用|禁用" disabled>';
                                }
                            }
                        },
                        {width: 200, toolbar: "#tool", title: '操作'}
                    ]
                ]
                , data: data
                , even: true
                , limit: data.length
                , toolbar: '#toolbar'
                , limits: [10, 30, 50, 100, 200, 500]
            });
        };
        // 二级联动 第一步 渲染父级
        CoreUtil.sendAjax("/sys/manage", null, function (resData) {
            var checkbox1="";
            $.each(resData.data, function (index, value) {
                // 这里的 value.roomName
                // 前者是页面显示的值，后者是传递给后台的值。
                // 正常情况下，后者应该是 value.id
                $('#Handoverdepart').append(new Option(value.departname, value.departname));	// 下拉菜单里添加元素
                $('#Handoverdeploy').append(new Option(value.departname, value.departname));

                checkbox1 += "<input type=\"checkbox\" name=\"deport1\" lay-skin=\"primary\" value=\""+ value.departname+"\">"+"&nbsp;"+value.departname+"&nbsp;&nbsp;&nbsp;";


            })
                $('#searchForm1').append(checkbox1);

        }, "GET", false);

        CoreUtil.sendAjax("/sys/fun", null, function (resData) {
            var checkbox1="";
            $.each(resData.data, function (index, value) {
                // 这里的 value.roomName
                // 前者是页面显示的值，后者是传递给后台的值。
                // 正常情况下，后者应该是 value.id
                $('#Handoverfun').append(new Option(value.funname, value.funname));	// 下拉菜单里添加元素
                checkbox1 += "<input type=\"checkbox\" name=\"fun1\" lay-skin=\"primary\" value=\""+ value.funname+"\">"+"&nbsp;"+value.funname+"&nbsp;&nbsp;&nbsp;";
            })
            $('#searchForm').append(checkbox1);
        }, "GET", false);

        // 条件查询配置
        $("#search").click(function () {
            var funs =[];
            var deports=[];
            $("#searchForm [name=fun1]:checked").each(function () {
                funs.push(this.value);
            })
            $("#searchForm1 [name=deport1]:checked").each(function () {
                deports.push(this.value);
            })
            searchParam.funs=funs;
            searchParam.deports=deports;
            searchParam.searContent = $("#searContent").val();
            searchParam.pageNum = 1;
            CoreUtil.sendAjax("/sys/indoors", JSON.stringify(searchParam), function (res) {
                laypageTable(res.data.totalRows, searchParam.pageNum);
                if (res.data.list != null) {
                    loadTable(res.data.list);
                }
            }, "POST", false, function (res) {
                layer.msg("抱歉！您暂无获取用户列表的权限");
                var noAuthorityData = [];
                loadTable(noAuthorityData);
            });
        });
        // 表内事件
        table.on('tool(house_table)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'del':
                    deletedHome(data.houserid,data.homeid,data.homename);
                    break;
                case 'edit':
                    $(".house_table_div").hide();
                    $(".operation_house").show();
                    $(".title").html("编辑屋内信息");
                    $(".operation_house input[name=funid]").val(data.funid);
                    $(".operation_house input[name=homeid]").val(data.homeid);
                    $(".operation_house input[name=houserid]").val(data.houserid);
                    $(".operation_house input[name=housename]").val(data.housename);
                    // $(".operation_house input[name=housename]").next().addClass()
                    $(".operation_house input[name=floorspace]").val(data.floorspace);
                    $(".operation_house input[name=area]").val(data.area);
                    $(".operation_house input[name=level]").val(data.level);
                    $(".operation_house input[name=regionspace]").val(data.regionspace);
                    $(".operation_house input[name=homenum]").val(data.homenum);
                    $(".operation_house input[name=homename]").val(data.homename);
                    $(".operation_house input[name=fun]").val(data.fun);
                    $(".operation_house input[name=funuse]").val(data.funuse);
                    $(".operation_house input[name=depart]").val(data.depart);
                    $(".operation_house input[name=deploy]").val(data.deploy);
                    $(".operation_house input[name=enterprise]").val(data.enterprise);
                    $(".operation_house input[name=forclass]").val(data.forclass);
                    $(".operation_house input[name=remark]").val(data.remark);
                    $(".operation_house input[name=detailone]").val(data.detailone);
                    $(".operation_house input[name=detailtwo]").val(data.detailtwo);
                    $(".operation_house input[name=detailthree]").val(data.detailthree);
                    if (data.status == 0) {
                        $(".operation_house input[name=status]").attr('checked', 'checked');
                        $(".operation_house input[name=status]").attr('type', 'hidden').val(0);
                        var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                        x[0].setAttribute("class", "layui-unselect layui-form-switch layui-form-onswitch");
                        var d = document.getElementsByTagName('em')[1];
                        d.firstChild.nodeValue = '启用';
                    } else {
                        $(".operation_house input[name=status]").attr('type', 'hidden').removeAttr("checked").val(1);
                        var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                        x[0].setAttribute("class", "layui-unselect layui-form-switch");
                        var d = document.getElementsByTagName('em')[0];
                        d.firstChild.nodeValue = '禁用';
                    }
                    form.render(); //更新全部

                    break;
                case 'addIndoor':
                    $(".house_table_div").hide();
                    $(".operation_house").show();
                    $(".title").html("新增区域信息");
                    $(".operation_house input[name=funid]").val("");
                    $(".operation_house input[name=homeid]").val("");
                    $(".operation_house input[name=houserid]").val(data.houserid);
                    $(".operation_house input[name=housename]").val(data.housename).attr("disabled","disabled");
                    $(".operation_house input[name=floorspace]").val(data.floorspace).attr("disabled","disabled");
                    $(".operation_house input[name=area]").val(data.area).attr("disabled","disabled");
                    $(".operation_house input[name=level]").val(data.level).attr("disabled","disabled");
                    $(".operation_house input[name=regionspace]").val("");
                    $(".operation_house input[name=homenum]").val("");
                    $(".operation_house input[name=homename]").val("");
                    $(".operation_house input[name=fun]").val("");
                    $(".operation_house input[name=funuse]").val("");
                    $(".operation_house input[name=depart]").val("");
                    $(".operation_house input[name=deploy]").val("");
                    $(".operation_house input[name=enterprise]").val("");
                    $(".operation_house input[name=forclass]").val("");
                    $(".operation_house input[name=remark]").val("");
                    $(".operation_house input[name=detailone]").val("");
                    $(".operation_house input[name=detailtwo]").val("");
                    $(".operation_house input[name=detailthree]").val("");
                    $(".operation_house input[name=status]").attr('checked', 'checked');
                    $(".operation_house input[name=status]").attr('type', 'hidden').val(0);
                    var x = document.getElementsByClassName("layui-unselect layui-form-switch");
                    x[0].setAttribute("class", "layui-unselect layui-form-switch layui-form-onswitch");
                    var d = document.getElementsByTagName('em')[0];
                    d.firstChild.nodeValue = '启用';
                    form.render(); //更新全部
                    break;

            }
        });

        // 表头操作
        table.on('toolbar(house_table)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id)

            switch (obj.event) {
                case 'addHouse':
                    $(".house_table_div").hide();
                    $(".operation_houser").show();
                    $(".title").html("新增房屋信息");
                    $(".operation_house input[name=housename]").val("");
                    $(".operation_house input[name=floorspace]").val("");
                    $(".operation_house input[name=area]").val("");
                    $(".operation_house input[name=level]").val("");
                    form.render(); //更新全部
                    break;
                case 'getCheckData':
                    var data = checkStatus.data;
                    if(data.length==0){
                        layer.msg("请选择要批量删除的日志");
                    }else {
                        var homeIds = [];
                        $(data).each(function (index,item) {
                            homeIds.push(item.homeid);
                        });
                        tipHouse(homeIds);
                    }
                    break;
            }

        });
        //删除前确认对话框 批量删除
        var tipHouse=function (homeIds) {
            layer.open({
                content: '确定要删除么',
                yes: function(index, layero){
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/sys/indoors",JSON.stringify(homeIds),function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    },"DELETE",false,function (res) {
                        layer.msg("抱歉！您暂无删除操作日志的权限");
                    });
                }
            });
        }

        //    删除house
        var deletedHouse = function (houserid) {
            layer.open({
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/sys/house/" + houserid, null, function (res) {
                        layer.msg(res.msg);
                    }, "DELETE", false, function (res) {
                        layer.msg("抱歉！您暂无删除房屋数据的权限");
                    });
                }
            });
        };

        // 删除home
        var deletedHome = function (houserid,homeid, homename) {
            layer.open({
                content: '确定要删除' + homename + "?",
                yes: function (index, layero) {
                    layer.close(index); //如果设定了yes回调，需进行手工关闭
                    CoreUtil.sendAjax("/sys/indoor/" + homeid, null, function (res) {
                        layer.msg(res.msg);
                        $(".layui-laypage-btn").click();
                    }, "DELETE", false, function (res) {
                        layer.msg("抱歉！您暂无删除屋内数据的权限");
                    });
                }

            });

        };

        // // 查看返回按钮
        $("#btn_cancel").click(function () {
            $(".house_table_div").show();
            $(".operation_house").hide();
            return false;
        });
        $("#btn_canceler").click(function () {
            $(".house_table_div").show();
            $(".operation_house").hide();
            $(".operation_houser").hide();
            return false;
        });

        $("#btn_canceler").click(function () {
            $(".house_table_div").show();
            $(".operation_house").hide();
            $(".operation_houser").hide();
            return false;
        });


        //表单选择器
        form.on('switch(switch)', function () {
            $(".operation_house input[name=status]").attr('type', 'hidden').val(this.checked ? 0 : 1);
        });
        //表单
        form.on('submit(submit)', function (data) {
            if (data.field.homeid === undefined || data.field.homeid === null || data.field.homeid === "") {
                CoreUtil.sendAjax("/sys/indoor", JSON.stringify(data.field), function (res) {
                    $(".house_table_div").show();
                    $(".operation_house").hide();
                    $(".operation_houser").hide();
                    $(".layui-laypage-btn").click();
                }, "POST", false, function (res) {
                    layer.msg("抱歉！您暂无新增区域的权限");
                });
            } else {
                CoreUtil.sendAjax("/sys/indoor", JSON.stringify(data.field), function (res) {

                    $(".house_table_div").show();
                    $(".operation_house").hide();
                    $(".operation_houser").hide();
                    $(".layui-laypage-btn").click();
                }, "PUT", false, function (res) {
                    layer.msg("抱歉！您暂无编辑部门的权限");
                });
            }

            return false;
        });
        form.on('submit(submiter)', function (data) {
                if (data.field.homeid === undefined || data.field.homeid === null || data.field.homeid === "") {
                    CoreUtil.sendAjax("/sys/house", JSON.stringify(data.field), function (res) {
                        $(".house_table_div").show();
                        $(".operation_houser").hide();
                        $(".layui-laypage-btn").click();
                    }, "POST", false, function (res) {
                        layer.msg("抱歉！您暂无新增区域的权限");
                    });
                } else {
                    CoreUtil.sendAjax("/sys/house", JSON.stringify(data.field), function (res) {

                        $(".house_table_div").show();
                        $(".operation_houser").hide();
                        $(".layui-laypage-btn").click();
                    }, "PUT", false, function (res) {
                        layer.msg("抱歉！您暂无编辑部门的权限");
                    });
                }

                return false;
            });


        form.on('select(Handoverdepart)', function (data) {   //选择移交单位 赋值给input框
            $("#depart").val(data.value);
            $("#Handoverdepart").next().find("dl").css({"display": "none"});
            form.render();
        });
        window.search = function () {
            var value = $("#depart").val();
            $("#Handoverdepart").val(value);
            form.render();
            $("#Handoverdepart").next().find("dl").css({"display": "block"});
            var dl = $("#Handoverdepart").next().find("dl").children();
            var j = -1;
            for (var i = 0; i < dl.length; i++) {
                if (dl[i].innerHTML.indexOf(value) <= -1) {
                    dl[i].style.display = "none";
                    j++;
                }
                if (j == dl.length - 1) {
                    $("#Handoverdepart").next().find("dl").css({"display": "none"});
                }
            }

        };
        form.on('select(Handoverdeploy)', function (data) {   //选择移交单位 赋值给input框
            $("#deploy").val(data.value);
            $("#Handoverdeploy").next().find("dl").css({"display": "none"});
            form.render();
        });
        window.searcher = function () {
            var value = $("#deploy").val();
            $("#Handoverdeploy").val(value);
            form.render();
            $("#Handoverdeploy").next().find("dl").css({"display": "block"});
            var dl = $("#Handoverdeploy").next().find("dl").children();
            var j = -1;
            for (var i = 0; i < dl.length; i++) {
                if (dl[i].innerHTML.indexOf(value) <= -1) {
                    dl[i].style.display = "none";
                    j++;
                }
                if (j == dl.length - 1) {
                    $("#Handoverdeploy").next().find("dl").css({"display": "none"});
                }
            }

        };

        form.on('select(Handoverfunuse)', function (data) {   //选择移交单位 赋值给input框
            $("#funuse").val(data.value);
            $("#Handoverfunuse").next().find("dl").css({"display": "none"});
            form.render();
        });
        window.searchuse = function () {
            var value = $("#funuse").val();
            $("#Handoverfunuse").val(value);
            form.render();
            $("#Handoverfunuse").next().find("dl").css({"display": "block"});
            var dl = $("#Handoverfunuse").next().find("dl").children();
            var j = -1;
            for (var i = 0; i < dl.length; i++) {
                if (dl[i].innerHTML.indexOf(value) <= -1) {
                    dl[i].style.display = "none";
                    j++;
                }
                if (j == dl.length - 1) {
                    $("#Handoverfunuse").next().find("dl").css({"display": "none"});
                }
            }

        };

        form.on('select(Handoverfun)', function (data) {   //选择移交单位 赋值给input框
            $("#fun").val(data.value);
            $("#Handoverfun").next().find("dl").css({"display": "none"});
            CoreUtil.sendAjax("/sys/fun/" + data.value, null, function (res) {
                var optionstring = "";
                $.each(res.data, function (i, item) {
                    optionstring += "<option value=\"" + item.funname + "\" >" + item.funname + "</option>";
                });
                $("#Handoverfunuse").html('<option value=""></option>' + optionstring);
                form.render('select');
            }, "GET", false);
            form.render();
        });
        window.searchuse = function () {
            var value = $("#fun").val();
            $("#Handoverfun").val(value);
            form.render();
            $("#Handoverfun").next().find("dl").css({"display": "block"});
            var dl = $("#fHandoverun").next().find("dl").children();
            var j = -1;
            for (var i = 0; i < dl.length; i++) {
                if (dl[i].innerHTML.indexOf(value) <= -1) {
                    dl[i].style.display = "none";
                    j++;
                }
                if (j == dl.length - 1) {
                    $("#Handoverfun").next().find("dl").css({"display": "none"});
                }
            }

        };


    });
</script>
</html>